package com.joe.gui.jdk6;

import java.awt.Frame;
import java.awt.Point;
import java.awt.Polygon;
import javax.swing.JDialog;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;

/**
 * 不规则窗体容器
 * @author Chen Wei
 */
public class SplashWindow extends JDialog {

    private Canvas canvas = new Canvas();

    public SplashWindow(Frame owner) {
        super(owner);
        this.getContentPane().add(canvas, java.awt.BorderLayout.CENTER);
        this.setAlwaysOnTop(true);
        this.setUndecorated(true);
        this.pack();
    }

    public static void main(String args[]) {

        try {
            UIManager.setLookAndFeel("com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel");
        } catch (ClassNotFoundException ex) {
        } catch (InstantiationException ex) {
        } catch (IllegalAccessException ex) {
        } catch (UnsupportedLookAndFeelException ex) {
        }
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                Point[] points = new Point[]{
                    new Point(115,80),
                    
                    new Point(125,80),
                    new Point(125,114),
                    new Point(170,114),
                    new Point(177,108),
                    new Point(177,94),
                    new Point(170,89),
                    new Point(125,89),
                    new Point(125,80),
                    
                    new Point(177,80),
                    new Point(184,83),
                    new Point(188,89),
                    new Point(188,112),
                    new Point(187,118),
                    new Point(196,118),
                    new Point(196,87),
                    
                    new Point(209,87),
                    new Point(209,118),
                    new Point(231,118),
                    new Point(212,87),
                    
                    new Point(226,87),
                    new Point(244,113),
                    new Point(261,87),
                    
                    new Point(273,87),
                    new Point(255,118),
                    new Point(278,118),
                    new Point(296,105),
                    new Point(273,87),
                    
                    new Point(290,87),
                    new Point(305,99),
                    
                    new Point(303,111),
                    new Point(292,118),
                    new Point(313,118),
                    new Point(303,111),
                    new Point(305,99),
                    
                    new Point(355,72),
                    new Point(356,72),
                    new Point(314,105),
                    new Point(333,118),
                    new Point(498,118),
                    new Point(498,334),
                    new Point(135,334),
                    new Point(135,122),
                    new Point(115,122)
                };
                Polygon polygon = new Polygon();
                for(int i = 0; i < points.length; i++){
                    polygon.addPoint(points[i].x, points[i].y);
                }

                SplashWindow dialog = new SplashWindow(new javax.swing.JFrame());
                dialog.setLocationRelativeTo(null);
                dialog.setVisible(true);
                com.sun.awt.AWTUtilities.setWindowShape(dialog, polygon);
            }
        });
    }
}
